#include "../include/objectPoint.h"

objectPoint::objectPoint(double theta, int index)
{
    setTheta(theta);
    Index = index;
}

objectPoint::objectPoint(PointF p)
{
    setPointXY(p);
}

objectPoint::objectPoint(double x, double y)
{
    setX(x);
    setY(y);
}
objectPoint::objectPoint()
{
objectPoint(0.0, 0.0);
}
string objectPoint::toString()
{
     ostringstream ss;
     ss<<"( "<<getX()<<", "<< getY() <<" )";
    return ss.str();
}
double objectPoint::getDistanceFromPoint(objectPoint p)
{
    double dx = _X - p._X;
    double dy = _Y - p._Y;
    return sqrt(dx * dx + dy * dy);
}

double objectPoint::GetDegreeFrom(objectPoint p)
{
    double dx = _X - p._X;
    double dy = _Y - p._Y;
    return atan2(dy, dx);
}

void objectPoint::Set_Theta(double t)
{
    _theta = t;
    _COS = cos(_theta);
    _SIN = sin(_theta);
}
void objectPoint::Set_Theta()
{
    Set_Theta( atan2(_Y, _X) );
    _R = sqrt(_X * _X + _Y * _Y);
}
void objectPoint::SetXY(double x, double y)
{
    _X = x;
    _Y = y;
    Set_Theta();
}
